package au.edu.swin.videoshop.bean;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class Classification implements Comparable, Serializable {
	private static final Map sMap = new HashMap();
	
	public static final Classification G = new Classification(1, "G", "General", "/images/icons/classification_g.png");
	public static final Classification PG = new Classification(2, "PG", "Parental Guidance", "/images/icons/classification_pg.png");
	public static final Classification M = new Classification(3, "M", "Mature", "/images/icons/classification_m.png");
	public static final Classification MA = new Classification(4, "MA", "Mature Accompanied", "/images/icons/classification_ma.png");
	public static final Classification R = new Classification(5, "R", "Restricted", "/images/icons/classification_r.png");
	public static final Classification X = new Classification(6, "X", "Pornographic", "/images/icons/classification_x.png");
	
	private int mOrder;
	private String mName;
	private String mDescription;
	private String mIconUrl;
	
	private Classification(int order, String name, String description, String iconUrl) {
		mOrder = order;
		mName = name;
		mDescription = description;
		mIconUrl = iconUrl;
		
		sMap.put(name, this);
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return mName;
	}
	
	/**
	 * @return the description
	 */
	public String getDescription() {
		return mDescription;
	}
	
	/**
	 * @return the iconUrl
	 */
	public String getIconUrl() {
		return mIconUrl;
	}

	/* (non-Javadoc)
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(Object o) {
		return mOrder - ((Classification)o).mOrder;
	}
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return mName;
	}
	
	public static Classification getInstance(String name) {
		return (Classification)sMap.get(name);
	}
}
